package com.test.harmonyostest.slice;

import com.test.harmonyostest.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.animation.AnimatorValue;

public class MainAbilitySlice extends AbilitySlice {

    private static final String TAG = "MainAbilitySlice";

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        findComponentById(ResourceTable.Id_test).setClickedListener(component -> {
            log("component click");
            AnimatorValue va = new AnimatorValue();
            va.setDuration(600);
            va.setValueUpdateListener((animatorValue, v) -> {
                log("animator value:%f", v);
            });
            va.start();
        });
    }

    private static void log(String msg, Object... args) {
        System.out.println(String.format("%s:%s", TAG, String.format(msg, args)));
    }
}
